const { Router, Get, Inject, Schedule } = require('free-koa/decorator');
const UserModel = require("./model")
const service = require("./service")
@Router()
class index {

    @Inject(UserModel)
    UserModel;

    @Schedule('10 * * * * *')
    schedule() {
        console.log("这是一个定时任务")
    }

    @Get("/service")
    async service() {
        return service.test()
    }

    @Get("/list")
    async index() {
        console.log("日志")
        return await this.UserModel.findAll()
    }
    @Get("/add")
    async add() {
        return await this.UserModel.create({ id: Math.random(), name: Math.random() })
    }
}
module.exports = index;